package com.mall.cloud.service.fallback;

import com.mall.cloud.bean.User;
import com.mall.cloud.common.CommonResult;
import com.mall.cloud.common.ResultCode;
import com.mall.cloud.service.UserService;
import org.springframework.stereotype.Component;

@Component
public class UserFallbackService implements UserService {
    @Override
    public CommonResult<User> create(User user) {
        User userDefault = new User(100L, "沈同学");
        return new CommonResult<>(userDefault);
    }

    @Override
    public CommonResult<User> getUser(Long id) {
        User user = new User(34L, "张同学");
        return new CommonResult<>(user);
    }

    @Override
    public CommonResult<User> getByUsername(String username) {
        User user = new User(57L, "李同学");
        return new CommonResult<>(user);
    }

    @Override
    public CommonResult<User> update(User user) {
        return CommonResult.failed(ResultCode.FAILED);
    }

    @Override
    public CommonResult<User> delete(Long id) {
        return CommonResult.failed(ResultCode.FAILED);
    }
}
